<?php
// v0.1.0
class ReqParam {
	public $req = "";
	public $name = "";
}
class Req_sfslobby {
	const url = "http://127.0.0.1:38899/jinzun/lobbyHandler";
	static function http_post_data($url, $data_string) {
		$ch = curl_init ( $url );
		curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
		curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data_string );
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
		curl_setopt ( $ch, CURLOPT_TIMEOUT, 5 );
		curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
				'Content-Type: application/json',
				'Content-Length: ' . strlen ( $data_string ) 
		) );
		$data = curl_exec ( $ch );
		return $data;
	}
	/**
	 * 账号注册
	 *
	 * @param unknown $account        	
	 * @param unknown $nick        	
	 * @param unknown $password        	
	 * @return unknown
	 */
	function AccountRegist($account, $nick, $password, $agent, $phone) {
		$arr = new ReqParam ();
		$arr->req = '1';
		$arr->account = $account;
		$arr->nick = $nick;
		$arr->password = $password;
		$arr->agentname = $agent;
		$arr->phone = $phone;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 账号登录
	 *
	 * @param unknown $account        	
	 * @param unknown $nick        	
	 * @param unknown $password        	
	 * @return mixed
	 */
	function AccountLogin($account, $password) {
		$arr = new ReqParam ();
		$arr->req = '2';
		$arr->account = $account;
		$arr->password = $password;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 查询账号数据
	 *
	 * @param unknown $account        	
	 * @return mixed
	 */
	function QueryAccountData($account) {
		$arr = new ReqParam ();
		$arr->req = '3';
		$arr->account = $account;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 保存账号数据
	 *
	 * @param unknown $account        	
	 * @param unknown $coins        	
	 * @return mixed
	 */
	function SaveAccountData($account, $coins, $gamename) {
		$arr = new ReqParam ();
		$arr->req = '4';
		$arr->account = $account;
		$arr->coins = $coins;
		$arr->gamename = $gamename;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 查询用户状态
	 *
	 * @param unknown $account        	
	 * @return unknown
	 */
	function QueryAccountStatus($account) {
		$arr = new ReqParam ();
		$arr->req = '5';
		$arr->account = $account;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 保存用户信息
	 *
	 * @param unknown $account        	
	 * @param unknown $sex        	
	 * @param unknown $xingZuo        	
	 * @param unknown $sign        	
	 * @param unknown $adress        	
	 * @param unknown $phone        	
	 * @param unknown $weixin        	
	 * @param unknown $qq        	
	 * @param unknown $email        	
	 */
	function SaveUserInfo($account, $sex, $xingZuo, $sign, $adress, $phone, $weixin, $qq, $email) {
		$arr = new ReqParam ();
		$arr->req = '6';
		$arr->account = $account;
		$arr->sex = $sex;
		$arr->xingzuo = $xingZuo;
		$arr->sign = $sign;
		$arr->adress = $adress;
		$arr->phone = $phone;
		$arr->weixin = $weixin;
		$arr->qq = $qq;
		$arr->email = $email;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 查询充值/使用记录
	 *
	 * @param unknown $account        	
	 * @param unknown $type        	
	 * @return mixed
	 */
	function QueryDataRecord($account, $type) {
		$arr = new ReqParam ();
		$arr->req = '7';
		$arr->account = $account;
		$arr->type = $type;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 金币兑换
	 *
	 * @param unknown $account        	
	 * @param unknown $name        	
	 * @param unknown $phone        	
	 * @param unknown $platform        	
	 * @param unknown $coins        	
	 * @return mixed
	 */
	function CoinsExchange($account, $name, $phone, $platform, $coins) {
		$arr = new ReqParam ();
		$arr->req = '8';
		$arr->account = $account;
		$arr->name = $name;
		$arr->phone = $phone;
		$arr->platform = $platform;
		$arr->coins = $coins;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 绑定代理
	 *
	 * @param unknown $account        	
	 * @param unknown $agentname        	
	 * @return mixed
	 */
	function BindingAgent($account, $agentname) {
		$arr = new ReqParam ();
		$arr->req = '9';
		$arr->account = $account;
		$arr->agentname = $agentname;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 快速开始
	 *
	 * @param unknown $account        	
	 * @param unknown $scane        	
	 * @param unknown $roomName        	
	 * @param unknown $dealer        	
	 * @param unknown $roomnum        	
	 */
	function UserLastEnterGameRecord($account) {
		$arr = new ReqParam ();
		$arr->req = '10';
		$arr->account = $account;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 修改密码
	 *
	 * @param unknown $account        	
	 * @param unknown $password        	
	 * @return mixed
	 */
	function ResetPassword($account, $password) {
		$arr = new ReqParam ();
		$arr->req = '11';
		$arr->account = $account;
		$arr->password = $password;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 获取游戏信息
	 *
	 * @param unknown $gameId        	
	 * @return mixed
	 */
	function GetGameInfo($gameId) {
		$arr = new ReqParam ();
		$arr->req = '12';
		$arr->gameindex = $gameId;
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
	/**
	 * 获取大厅设置
	 *
	 * @return mixed
	 */
	function GetLobbySetting() {
		$arr = new ReqParam ();
		$arr->req = '13';
		$json_string = json_encode ( $arr );
		return Req_sfslobby::http_post_data ( Req_sfslobby::url, $json_string );
	}
}